home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / prof / profMigrate.c < prev    next >
C/C++ Source or Header  |  1990-09-11  |  4KB  |  153 lines

  1. /* 
  2.  * profMigrate.c --
  3.  *
  4.  *    Routines to handle profiling for migrated procedures.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/kernel/prof/RCS/profMigrate.c,v 9.1 90/09/11 12:05:07 rab Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20.  
  21. #include "sprite.h"
  22. #include "stdio.h"
  23. #include "proc.h"
  24. #include "procMigrate.h"
  25. #include "status.h"
  26. #include "prof.h"
  27.  
  28. /* 
  29.  * Information sent for profiling.
  30.  */
  31.  
  32. typedef struct {
  33.     short *Prof_Buffer;
  34.     int Prof_BufferSize;
  35.     int Prof_Offset;
  36.     int Prof_Scale;
  37. } EncapState;
  38.  
  39.  
  40. /*
  41.  *----------------------------------------------------------------------
  42.  *
  43.  * Prof_GetEncapSize --
  44.  *
  45.  *    Returns the size of the storage area used to record profiling
  46.  *      information that is sent with a migrated process.
  47.  *
  48.  * Results:
  49.  *    SUCCESS is returned directly; the size of the encapsulated state
  50.  *    is returned in infoPtr->size.
  51.  *
  52.  * Side effects:
  53.  *    None.
  54.  *
  55.  *----------------------------------------------------------------------
  56.  */
  57.  
  58. /* ARGSUSED */
  59. ReturnStatus
  60. Prof_GetEncapSize(procPtr, hostID, infoPtr)
  61.     Proc_ControlBlock *procPtr;            /* process being migrated */
  62.     int hostID;                    /* host to which it migrates */
  63.     Proc_EncapInfo *infoPtr;            /* area w/ information about
  64.                          * encapsulated state */
  65. {
  66.     infoPtr->size = sizeof(EncapState);
  67.     return SUCCESS;
  68. }
  69.  
  70.  
  71. /*
  72.  *----------------------------------------------------------------------
  73.  *
  74.  * Prof_EncapState --
  75.  *
  76.  *    Encapsulate the profiling information to be sent with
  77.  *      a migrated process.  If the processes is being profiled,
  78.  *      then turn if off.
  79.  *
  80.  * Results:
  81.  *    SUCCESS.
  82.  *
  83.  * Side effects:
  84.  *    Disables profiling of the process.
  85.  *
  86.  *----------------------------------------------------------------------
  87.  */
  88.  
  89. /* ARGSUSED */
  90. ReturnStatus
  91. Prof_EncapState(procPtr, hostID, infoPtr, ptr)
  92.     register Proc_ControlBlock     *procPtr;  /* The process being migrated */
  93.     int hostID;                   /* host to which it migrates */
  94.     Proc_EncapInfo *infoPtr;           /* area w/ information about
  95.                         * encapsulated state */
  96.     Address ptr;               /* Pointer to allocated buffer */
  97. {
  98.     EncapState *encapPtr;
  99.  
  100.     encapPtr = (EncapState *) ptr;
  101.     encapPtr->Prof_Buffer = procPtr->Prof_Buffer;
  102.     encapPtr->Prof_BufferSize = procPtr->Prof_BufferSize;
  103.     encapPtr->Prof_Offset = procPtr->Prof_Offset;
  104.     encapPtr->Prof_Scale = procPtr->Prof_Scale;
  105.     if (procPtr->Prof_Scale) {
  106.     Prof_Disable(procPtr);
  107.     }
  108.     return SUCCESS;
  109. }
  110.  
  111.  
  112. /*
  113.  *----------------------------------------------------------------------
  114.  *
  115.  * Prof_DeencapState
  116.  *
  117.  *    De-encapsulate information that arrived with a migrated process.
  118.  *      If the process was being profiled at home, then turn profiling
  119.  *      on here.
  120.  *
  121.  * Results:
  122.  *    SUCCESS.
  123.  *
  124.  * Side effects:
  125.  *    May enable profiling of the process.
  126.  *
  127.  *----------------------------------------------------------------------
  128.  */
  129.  
  130. /* ARGSUSED */
  131. ReturnStatus
  132. Prof_DeencapState(procPtr, infoPtr, ptr)
  133.     register Proc_ControlBlock     *procPtr; /* The process being migrated */
  134.     Proc_EncapInfo *infoPtr;          /* information about the buffer */
  135.     Address ptr;              /* buffer containing data */
  136. {
  137.     EncapState *encapPtr;
  138.  
  139.     encapPtr = (EncapState *) ptr;
  140.     if (infoPtr->size != sizeof(EncapState)) {
  141.     if (proc_MigDebugLevel > 0) {
  142.         printf("Prof_DeencapState: warning: host %d tried to migrate onto this host with wrong structure size.  Ours is %d, theirs is %d.\n",
  143.            procPtr->peerHostID, sizeof(EncapState),
  144.            infoPtr->size);
  145.     }
  146.     return(PROC_MIGRATION_REFUSED);
  147.     }
  148.     procPtr->Prof_Scale = 0;
  149.     Prof_Enable(procPtr, encapPtr->Prof_Buffer, encapPtr->Prof_BufferSize,
  150.     encapPtr->Prof_Offset, encapPtr->Prof_Scale);
  151.     return SUCCESS;
  152. }
  153.